# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: David Phillips <dbphillipsnz gmail>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>

_gemname=colorize
pkgname=ruby-colorize
_gitcommit=7c0b50a278da01870be4435ec1b5753c2544e8f3
pkgver=0.8.1
pkgrel=9
pkgdesc='Ruby string class extension to set color, background and text effect using ANSI escape sequences'
url='https://github.com/fazibear/colorize'
arch=('any')
license=('GPL2')
depends=('ruby')
makedepends=('ruby-rdoc')
options=('!emptydirs')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/fazibear/colorize/archive/${_gitcommit}.tar.gz)
sha256sums=('3ab2b2c87443fe8565a6a771592e372be6140e7b77372198b6d78a07861a362a')
sha512sums=('3b116a65913a242b2c8eb987b6e96d86f32ab08e776943288a09a8cd389f47a66a5fab10201e8dd98f4db0f05231d64a78ae10d9523c80545ef9e96ce8ce30f7')

prepare() {
  cd ${_gemname}-${_gitcommit}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec # don't give a fuck about rubys bla bla
  # remove deprecated `date` element from gemspec. Removing it makes the package reproducible
  sed --in-place '/s\.date/d' "${_gemname}.gemspec"
}

build() {
  cd ${_gemname}-${_gitcommit}
  gem build ${_gemname}.gemspec
}


package() {
  cd ${_gemname}-${_gitcommit}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}/${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 README.md CHANGELOG -t "${pkgdir}/usr/share/doc/${pkgname}"
  rm "${pkgdir}/${_gemdir}/cache/${_gemname}-${pkgver}.gem"
}

# vim: ts=2 sw=2 et:
